package com.timoon.webcomponent.utility.product.linepic.component;

import org.apache.wicket.markup.html.WebPage;
import org.apache.wicket.markup.html.image.Image;
import org.apache.wicket.markup.html.link.BookmarkablePageLink;
import org.apache.wicket.markup.html.panel.Panel;
import org.apache.wicket.request.mapper.parameter.PageParameters;
import org.apache.wicket.request.resource.PackageResourceReference;

import com.timoon.sample.dao.model.Product;

/**
 *<p>单独一个小商品图片，用户建立商品图片grid</p>
 *<p></p>
 *<p>Copyright:Copyright(c)2013</p>
 *<p>Company:timoon</p>
 *@author 付乐天
 *@version 1.0 */

public class SingleSmallPicProductPanel extends Panel {
	
	private Class<? extends WebPage> targetPage;
	
	private Product product;

	public SingleSmallPicProductPanel(String id,Product product,Class<? extends WebPage> targetPage) {
		super(id);
		// TODO Auto-generated constructor stub
		this.targetPage=targetPage;
		
		this.product=product;
		
		renderPanel();
	}

	private void renderPanel() {
		// TODO Auto-generated method stub
		
		renderImg();
	}

	private void renderImg() {
		// TODO Auto-generated method stub
		
		PageParameters pageParameters=new PageParameters();
		pageParameters.set("product_id", product.getId());
		BookmarkablePageLink link=new BookmarkablePageLink<>("wk_link", targetPage,pageParameters);
		add(link);
		
		link.add(new Image("wk_img",new PackageResourceReference(this.getClass(),"name.jpg")));
	}

}
